The present invention relates generally to file systems for mass storage devices, and pertains more particularly to a virtual file system for a peripheral device that provides a large block-oriented mass storage device interface to a host system while using a much smaller amount of memory in the peripheral device and dynamically generating the data blocks read by the host.
Mass storage peripherals, such as disk drives, are in common use in computer systems today for storing and retrieving data. This data is stored in blocks. Many different logical sets of data, commonly referred to as xe2x80x9cfilesxe2x80x9d, can be stored on the peripheral. While the data blocks are typically of a fixed size, a file can contain more data than can fit in a single data block, and so a file may consist of a number of data blocks. In addition, the various data blocks that make up a file do not need to be located together, but rather can be stored in different places on the peripheral. In order to facilitate access to files of data by the computer system, mass storage peripherals typically provide a file system which describes the organization on the peripheral of the data blocks for each file.
With conventional mass storage peripherals, data blocks are read and written only under the explicit control of the computer system. In other words, the computer system can keep its own independent record of where certain data blocks and files are stored on the peripheral and be assured that, in fact, that is where the data blocks and files are located. In order to speed up the storage and retrieval of frequently used data blocks, computer systems also frequently implement a data block cache internal to the computer system itself that stores these frequently accessed data blocks. The computer system can read a data block from the cache much more quickly than it can from the peripheral, and so computer systems typically search their cache for a desired data block, and request it from the peripheral only if it is not found in the cache.
The above-described caching mechanism works well in the case of traditional mass storage peripherals, such as disk drives, in which data blocks are only read and written under the explicit control of the computer system. Such disk drives also generally have large enough amounts of memory to store the tables that implement the file system, as well as the data blocks for all the files. However, certain intelligent mass storage peripherals, such as one described in the above-referenced co-pending and commonly owned patent application by Holcomb et al., may dynamically create, delete, or rearrange data blocks independent of the explicit control of the computer system. As a result, the computer system can no longer be assured that the data blocks in its cache match the data blocks on the peripheral, and incorrect operation can result when the computer system reads cached files rather than obtaining files from the peripheral. In order to ensure proper operation, the peripheral must inform the computer system each time it dynamically creates, deletes, or rearranges data blocks, and the computer system must delete and rebuild the cache and other file system tables. Some computer systems provide a mechanism for the peripheral to so inform the computer system; however, the actions to delete and rebuild the cache and other file system tables can be time-consuming and inefficient. Other computer systems do not support such a mechanism at all.
A related limitation of non-traditional peripherals is that they may not contain sufficient memory to store all the data blocks needed to provide a large file system. As a result, the number and size of files stored on the peripheral may be disadvantageously limited, thus requiring the peripheral to dynamically delete certain files and create others, and giving rise to the previously discussed synchronization problem between the computer system and the peripheral.
Accordingly, it would be highly desirable to have a new and improved file system and method of accessing a large number of data files which allows files to be created, deleted, and rearranged without requiring the host computer system to delete and rebuild its cache and other file system tables and without requiring a large amount of memory.
In a preferred embodiment, the present invention provides a virtual filesystem capable of including a large number of data files. The virtual filesystem has a predetermined structure of directories and files, and a linear filespace. The linear filespace includes a directory region and a file allocation table region in which, as a result of the predetermined nature of the directory structure, the data blocks are calculatable upon a read request and are not required to be stored in the filesystem. The linear filespace also includes a file region having a predefined number of predefined-size files. Each of a set of lowest-level directories of the directory structure contains a single file. The particular single file in the file region that is linked to a particular lowest-level directory is preferably determined at the time when the lowest-level directory is first accessed, thus allowing a previously-unused or least-recently-used one of the files to be allocated so as to avoid the need to delete and rebuild the host""s cache. The data blocks of the file are preferably dynamically generated and provided to the virtual filesystem upon request, or aliased to a file stored in an auxiliary filesystem that is read via the virtual filesystem.